@include('admin.header')
<style>
  .btnSeach{
    background: rgb(29, 204, 170) none repeat scroll 0 0;
    border: 2px solid rgb(29, 204, 170);
    border-radius: 5px;
    color: white;
    font-weight: bold;
    margin-bottom: 10px;
    margin-left: 300px;
    padding: 6px;
    position: absolute;
  }
</style>
<div class="margin-top-20">
    <div class="cl pd-5 bg-1 bk-gray mt-20" style="margin-left:200px;">

      报单手机号：
      <input type="text" name="user_account" style="width:250px" class="input-text input_search" value=""><span class="btnSeach team_recharge_list">手动报单记录</span><br/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;报单PV：
      <input type="text" name="recharge_amount"  style="width:250px" class="input-text input_search" value="">

    </div>



  <form id="team_recharge_form">
    {{ csrf_field() }}
    <table class="table table-border table-bordered table-hover">
      <tr>
        <td></td>
        <td>报单用户</td>
        <td>直接推荐人</td>
        <td>间接推荐人</td>
      </tr>
      <tr>
        <td>用户手机号</td>
        <td><input type="text" class="input-text" name="user_nodecode"/></td>
        <td><input type="text" class="input-text" name="intro_nodecode"/></td>
        <td><input type="text" class="input-text" name="intro2_nodecode"/></td>
      </tr>
      <tr>
        <td>是否是VIP</td>
        <td><span class="user_vip"></span></td>
        <td><span class="intro_vip"></span></td>
        <td><span class="intro2_vip"></span></td>
      </tr>
      <tr>
        <td>返还储值积分</td>
        <td><input type="text" class="input-text" name="user_shop"/></td>
        <td><input type="text" class="input-text" name="intro_shop"/></td>
        <td><input type="text" class="input-text" name="intro2_shop"/></td>
      </tr>
      <tr>
        <td>返还浩联积分</td>
        <td><input type="text" class="input-text" name="user_ga"/></td>
        <td><input type="text" class="input-text" name="intro_ga"/></td>
        <td><input type="text" class="input-text" name="intro2_ga"/></td>
      </tr>
      <tr>
        <td>返还全球积分</td>
        <td><input type="text" class="input-text" name="user_hl"/></td>
        <td><input type="text" class="input-text" name="intro_hl"/></td>
        <td><input type="text" class="input-text" name="intro2_hl"/></td>
      </tr>
      <tr>
        <td colspan="4" style="text-align: center">
          <span name="" id="submit" class="btn btn-success user_search"><i class="Hui-iconfont"></i> 确定</span>
        </td>
      </tr>
    </table>
  </form>
</div>


<script>
  $(function () {
    // 输入手机号失去焦点事件
    $("[name=user_account]").blur(function(){
      $nodecode = $(this).val();
      if(!$nodecode){
        return false;
      }

      $.get("{{url('ucenter/get_user_introducer')}}" , {'nodecode':$nodecode} , function(result){
        if(result['node']){
          $("[name=user_nodecode]").val(result['node']['nodecode']);
          $(".user_vip").html(vip_level(result['node']['vipLevel']));
        }
        if(result['intro']){
          $("[name=intro_nodecode]").val(result['intro']['nodecode']);
          $(".intro_vip").html(vip_level(result['intro']['vipLevel']));
        }
        if(result['intro2']){
          $("[name=intro2_nodecode]").val(result['intro2']['nodecode']);
          $(".intro2_vip").html(vip_level(result['intro2']['vipLevel']));
        }
      } , 'json');
    });

    // 输入金额后算出相应返还的积分
    $("[name=recharge_amount]").blur(function(){
      $pv = $(this).val();
      // 数组百分比为 储值，浩联，全球
      $user = [100 , 0 , 0];
      $intro = [0 , 10 , 10];
      $intro2 = [30 , 0 , 0];

      $("[name=user_shop]").val(Math.floor($pv * $user[0] / 100));
      $("[name=user_ga]").val(Math.floor($pv * $user[1] / 100));
      $("[name=user_hl]").val(Math.floor($pv * $user[2] / 100));

      $("[name=intro_shop]").val(Math.floor($pv * $intro[0] / 100));
      $("[name=intro_ga]").val(Math.floor($pv * $intro[1] / 100));
      $("[name=intro_hl]").val(Math.floor($pv * $intro[2] / 100));

      $("[name=intro2_shop]").val(Math.floor($pv * $intro2[0] / 100));
      $("[name=intro2_ga]").val(Math.floor($pv * $intro2[1] / 100));
      $("[name=intro2_hl]").val(Math.floor($pv * $intro2[2] / 100));
    });

    // 提交时间
    $('#submit').click(function(){
      var $data = $('#team_recharge_form').serialize();
      if(!$("[name=user_nodecode]").val()){
        alert('请输入报单的手机号');
        return false;
      }
      $('#submit').hide();
      $.post("{{url('ucenter/team_recharge')}}" , $data , function(result){
        alert(result['info']);
        window.location.reload();
      } , 'json');
    });

    function vip_level($level){
      var $res = '普通会员';
      if(1 == $level){
        $res = 'VIP';
      }else if(2 == $level){
        $res = 'SVIP';
      }
      return $res;
    }

    //订单详情
    $('.team_recharge_list').click(function(){
      //获取参数
      open_iframe_layer('/ucenter/team_recharge_list');
    });
  });
</script>